package com.example.crmdemo.Crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.crmdemo.Crm.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT * FROM users WHERE username = #{username}")
    User findByUsername(@Param("username") String username);

    @Select("SELECT * FROM users WHERE role = 'manager'")
    List<User> getAllManagers();

    @Select("SELECT * FROM users WHERE role = 'user'")
    List<User> getAllUsers();

    @Select("SELECT * FROM users WHERE role = 'user' and username = #{username}")
    List<User> getUserByUsername(@Param("username") String username);
}
